Xceed Toolkit Plus for WPF v5.0 Documentation
In This Topic
    Providing a CellContentTemplate
    In This Topic

    The following example demonstrates how to provide a new CellContentTemplate, using property element syntax, for a boolean column that displays a check mark when the cell's value is true, and an "x" when it is false.

    This example assumes that the grid is bound to the Products table of the Northwind database.

    XAML
    Copy Code
    <Grid xmlns:xcdg="http://schemas.xceed.com/wpf/xaml/datagrid">
      <Grid.Resources>
        <xcdg:DataGridCollectionViewSource x:Key="cvs_products"
                                        Source="{Binding Source={x:Static Application.Current},
                                                          Path=Products}"/>
      </Grid.Resources>
       <xcdg:DataGridControl x:Name="ProductsGrid"
                             ItemsSource="{Binding Source={StaticResource cvs_products}}">
          <xcdg:DataGridControl.Columns>
            <xcdg:Column FieldName="Discontinued">
               <xcdg:Column.CellContentTemplate>
                  <DataTemplate>
                     <Image x:Name="img" Source="D:\true.png" Stretch="None" />
                        <DataTemplate.Triggers>
                           <DataTrigger Binding="{Binding}" Value="False">
                             <Setter TargetName="img" Property="Source" Value="D:\false.png" />
                           </DataTrigger>
                        </DataTemplate.Triggers>
                  </DataTemplate>
               </xcdg:Column.CellContentTemplate>
            </xcdg:Column>
          </xcdg:DataGridControl.Columns>
       </xcdg:DataGridControl>
    </Grid>